package edu.luc.etl.jbunit.tl;

/**
 * The formula <code>! p</code> specifies that
 * <code>p</code> must be false in the current time unit.
 */

public class Not<T> extends Expr<T> {

  private Expr<T> e;

  public Not(Expr<T> e) {
    this.e = e;
  }

  public Not(T label) {
    this(new Leaf<T>(label));
  }

  public Not<T> clone() {
    Not<T> result = (Not<T>) super.clone();
    result.e = e.clone();
    return result;
  }

  public void reset () { e.reset(); }

  public void tick () { evaluated = false; e.tick(); }

  boolean ev () {
    boolean te = e.valuate();

    val = ! te; //(te ? false : true);
    return val;
  }

  void accept(Visitor<T> v) {
    v.visitNot(this);
    e.accept(v);
  }
}

